import request from '@/utils/request'
import { BaseResponse } from '../base'
import { Goods, GoodsReq } from './type'

export function getGoodsList(params: GoodsReq): Promise<BaseResponse> {
  return request({ url: '/campus/goods/page', method: 'get', params })
}
export function pageMe(params: GoodsReq): Promise<BaseResponse> {
  return request({ url: '/campus/goods/pageMe', method: 'get', params })
}

export function getGoodsDetail(id: number): Promise<BaseResponse> {
  return request({ url: `/campus/goods/detail/${id}`, method: 'get' })
}

export function publishGoods(data: Goods): Promise<BaseResponse> {
  return request({ url: '/campus/goods/publish', method: 'post', data })
}

export function deleteGoods(id: number): Promise<BaseResponse> {
  return request({ url: `/campus/goods/delete/${id}`, method: 'delete' })
}

export function updateGoods(data: Goods): Promise<BaseResponse> {
  return request({ url: '/campus/goods/update', method: 'put', data })
}

export function changeStatus(id: number, status: number): Promise<BaseResponse> {
  return request({ url: `/campus/goods/changeStatus/${id}/${status}`, method: 'put' })
}